#include "gtkwindow.h"
#include "gtkkineticscrolling.h"
#include "a11y/gtkscrolledwindowaccessible.h"
+#include "gtkstylecontextprivate.h"
#include <math.h>
* scrollbars are desired although no mouse is present, this behaviour
* can be turned off with the #GtkScrolledWindow:overlay-scrolling
* property.
+ *
+ * # CSS nodes
+ *
+ * GtkScrolledWindow has a main CSS node with name scrolledwindow.
+ * It uses transient subnodes with names overshoot and undershoot to
+ * draw the overflow and underflow indications. These nodes get
+ * the .left, .right, .top or .bottom style class added depending
+ * on where the indictaion is drawn. If both scrollbars are visible,
+ * the area where they meet is drawn with a transient subnode named
+ * junction.
*/
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE);
+ gtk_widget_class_set_css_name (widget_class, "scrolledwindow");
}
static gboolean
priv->window_placement == GTK_CORNER_TOP_RIGHT)
junction_rect.y += vscr_allocation.height;
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCROLLBARS_JUNCTION);
+ gtk_style_context_save_named (context, "junction");
gtk_render_background (context, cr,
junction_rect.x, junction_rect.y,
overshoot_x = CLAMP (overshoot_x, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
overshoot_y = CLAMP (overshoot_y, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
- gtk_style_context_save (context);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_OVERSHOOT);
+ gtk_style_context_save_named (context, "overshoot");
if (overshoot_x > 0)
{
gtk_style_context_restore (context);
- gtk_style_context_save (context);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_OVERSHOOT);
+ gtk_style_context_save_named (context, "overshoot");
if (overshoot_y > 0)
{
context = gtk_widget_get_style_context (widget);
gtk_scrolled_window_inner_allocation (widget, &rect);
- gtk_style_context_save (context);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_UNDERSHOOT);
-
adj = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
{
+ gtk_style_context_save_named (context, "undershoot");
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
gtk_render_background (context, cr, rect.x + rect.width - UNDERSHOOT_SIZE, rect.y, UNDERSHOOT_SIZE, rect.height);
gtk_render_frame (context, cr, rect.x + rect.width - UNDERSHOOT_SIZE, rect.y, UNDERSHOOT_SIZE, rect.height);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
+ gtk_style_context_restore (context);
}
if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
{
+ gtk_style_context_save_named (context, "undershoot");
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
gtk_render_background (context, cr, rect.x, rect.y, UNDERSHOOT_SIZE, rect.height);
gtk_render_frame (context, cr, rect.x, rect.y, UNDERSHOOT_SIZE, rect.height);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+ gtk_style_context_restore (context);
}
adj = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
{
+ gtk_style_context_save_named (context, "undershoot");
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
gtk_render_background (context, cr, rect.x, rect.y + rect.height - UNDERSHOOT_SIZE, rect.width, UNDERSHOOT_SIZE);
gtk_render_frame (context, cr, rect.x, rect.y + rect.height - UNDERSHOOT_SIZE, rect.width, UNDERSHOOT_SIZE);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_style_context_restore (context);
}
if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
{
+ gtk_style_context_save_named (context, "undershoot");
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
gtk_render_background (context, cr, rect.x, rect.y, rect.width, UNDERSHOOT_SIZE);
gtk_render_frame (context, cr, rect.x, rect.y, rect.width, UNDERSHOOT_SIZE);
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_style_context_restore (context);
}
-
- gtk_style_context_restore (context);
}
static gboolean